home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 …ember: Reference Library / Dev.CD Dec 96 RL / Dev.CD Dec 96 RL.toast / Technical Documentation / develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / Substitute MacApp files / UObject.cp < prev    next >
Encoding:
Text File  |  1996-07-01  |  23.6 KB  |  850 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UObject.cp
  3. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UOBJECT__
  7. #include "UObject.h"
  8. #endif
  9.  
  10. // MacApp
  11.  
  12. // MacApp
  13. //The following installed by CKopala 6/23/96
  14. //Doesn't compile for 68K without it.
  15. #if qDebug || qTheDebugger && !qPowerPC
  16.     #ifndef __UCLASSDESCITERATOR__
  17.     #include "UClassDescIterator.h"
  18.     #endif
  19.  
  20.     #ifndef __MEMORYHEAP__
  21.     #include "MemoryHeap.h"
  22.     #endif
  23.  
  24.     #ifndef __BESTFITHEAP__
  25.     #include "BestFitHeap.h"
  26.     #endif
  27.     
  28.     #ifndef __OBJECTHEAP__
  29.     #include "ObjectHeap.h"
  30.     #endif
  31. #endif
  32.  
  33. #if qDebug || qTheDebugger
  34.     #ifndef __UDEBUG__
  35.     #include "UDebug.h"
  36.     #endif
  37. #endif
  38.  
  39. #ifndef __UDEPENDENCIES__
  40. #include "UDependencies.h"
  41. #endif
  42.  
  43. #ifndef __UFAILURE__
  44. #include "UFailure.h"
  45. #endif
  46.  
  47. #ifndef __UMACAPPUTILITIES__
  48. #include "UMacAppUtilities.h"
  49. #endif
  50.  
  51. #ifndef __UMEMORY__
  52. #include "UMemory.h"
  53. #endif
  54.  
  55. #ifndef __USTREAM__
  56. #include "UStream.h"
  57. #endif
  58.  
  59. #if qDebug || qTheDebugger
  60.     #ifndef __UTHEDEBUGGER__
  61.     #include "UTheDebugger.h"
  62.     #endif
  63. #endif
  64.  
  65. // ANSI
  66.  
  67. #ifndef __STDIO__
  68. #include <stdio.h>
  69. #endif
  70.  
  71. // Voodoo Monkey
  72.  
  73. #if qInspector
  74.     #ifndef __NUBINSPECTORHOOKS__
  75.     #include "NubInspectorHooks.h"
  76.     #endif
  77. #endif
  78.  
  79. //BEGIN Added by C Kopala 6/14/96
  80. #if qDebug
  81. long gObjectCount = 0;
  82. Boolean gObjectCountingEnabled = FALSE;
  83. Boolean gPrintBaseClassInfo = FALSE;
  84. Boolean gPrintMacAppClassInfo = FALSE;
  85. Boolean gPrintAppClassInfo = FALSE;
  86. Boolean gAppUserFlag1 = FALSE;
  87. Boolean gAppUserFlag2 = FALSE;
  88. Boolean gAppUserFlag3 = FALSE;
  89. #endif    
  90. //END Added by C Kopala 6/14/96
  91.  
  92. #ifndef qMacApp
  93. #define qMacApp FALSE
  94. #endif
  95.  
  96. //----------------------------------------------------------------------------------------
  97. // Globals
  98. //----------------------------------------------------------------------------------------
  99.  
  100. // pObjectAllocationFlag is set to true in TObject::TObject, and set back to false in 
  101. // TObject::IObject and TObject::ReadFrom.  This is used to warn the programmer that forgets
  102. // to call TObject::IObject or TObject::ReadFrom.  Forgetting this means the inspector won't
  103. // know about the object.
  104.  
  105. #if qInspector
  106. static Boolean pObjectAllocationFlag;
  107. static TObject* pLastObject;
  108. #endif
  109.  
  110.  
  111. //========================================================================================
  112. // CLASS TObject
  113. //========================================================================================
  114. #undef Inherited
  115.  
  116. #pragma segment MAOpen
  117. MA_DEFINE_CLASS_M0(TObject);
  118.  
  119. //----------------------------------------------------------------------------------------
  120. // TObject::operator new:
  121. //----------------------------------------------------------------------------------------
  122. #pragma segment Main
  123.  
  124. void* TObject::operator new(size_t size)
  125. {
  126.    return MAOperatorNew(size);
  127. }
  128.  
  129. //----------------------------------------------------------------------------------------
  130. // TObject::operator delete:
  131. //----------------------------------------------------------------------------------------
  132. #pragma segment Main
  133.  
  134. void TObject::operator delete(void* obj)
  135. {
  136.     MAOperatorDelete(obj);
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. // TObject::TObject:
  141. //----------------------------------------------------------------------------------------
  142. #pragma segment ConstructorRes
  143.  
  144. TObject::TObject()
  145. {
  146. #if qInspector
  147.     if (pObjectAllocationFlag)
  148.     {
  149.         CStr255        message;
  150.         
  151.         if ( IsObject(pLastObject) )
  152.             pLastObject->GetClassName(message);
  153.         else
  154.             message = "Someone";
  155.         
  156.         message += " forgot to call IObject or ReadFrom!";
  157.  
  158.         fprintf(stderr, "%s\n", (char*)message);
  159.     }
  160.  
  161.     pObjectAllocationFlag = TRUE;        // set the flag
  162.     pLastObject = this;
  163. #endif
  164.  
  165. #if qDebug
  166. if (gPrintBaseClassInfo)
  167.     fprintf(stderr, " >>TObject constructor\n");
  168. IncrementObjectCount();
  169. #endif
  170.  
  171. } // TObject::TObject
  172.  
  173. //----------------------------------------------------------------------------------------
  174. // TObject destructor
  175. //----------------------------------------------------------------------------------------
  176. #pragma segment MADestructorRes
  177.  
  178. TObject::~TObject()
  179. {
  180. #if qDebug
  181. if (gPrintBaseClassInfo)
  182.     fprintf(stderr, " >>TObject destructor\n");
  183. DecrementObjectCount();
  184. #endif
  185. }
  186.  
  187. //BEGIN Added by C Kopala 6/14/96
  188. #if qDebug
  189. //----------------------------------------------------------------------------------------
  190. // TObject::PrintConstructorClassInfo
  191. //----------------------------------------------------------------------------------------
  192. #pragma segment MADestructorRes
  193. void TObject::PrintConstructorClassInfo()
  194. {
  195. ClassName theClassName;
  196. ClassID theClassId;
  197. size_t theClassSize;
  198.  
  199. if (gPrintMacAppClassInfo)
  200.     {
  201.         this -> GetClassName(theClassName);
  202.         theClassId = this -> GetClassID();
  203.         theClassSize = this -> GetClassSize();
  204.         fprintf(stderr, "Construct %s", (char*)theClassName);
  205.         fprintf(stderr, "@ %p", this);
  206.         fprintf(stderr, " Id=%d", theClassId);
  207.         fprintf(stderr, " Size=%d", theClassSize);
  208.         
  209.         if (gObjectCountingEnabled && gPrintMacAppClassInfo)                
  210.             PrintObjectCount();
  211.             
  212.         fprintf(stderr, "\n");
  213.     }
  214.     
  215. }
  216. #endif
  217.  
  218. #if qDebug
  219. //----------------------------------------------------------------------------------------
  220. // TObject::PrintDestructorClassInfo
  221. //----------------------------------------------------------------------------------------
  222. #pragma segment MADestructorRes
  223. void TObject::PrintDestructorClassInfo()
  224. {
  225. ClassName theClassName;
  226. ClassID theClassId;
  227. size_t theClassSize;
  228.  
  229. if (gPrintMacAppClassInfo)
  230.     {
  231.         this -> GetClassName(theClassName);
  232.         theClassId = this -> GetClassID();
  233.         theClassSize = this -> GetClassSize();
  234.         fprintf(stderr, "Destruct %s", (char*)theClassName);
  235.         fprintf(stderr, "@ %p", this);
  236.         fprintf(stderr, " Id=%d", theClassId);
  237.         fprintf(stderr, " Size=%d", theClassSize);
  238.         
  239.         if (gObjectCountingEnabled)                
  240.             PrintObjectCount();
  241.             
  242.         fprintf(stderr, "\n");
  243.     }
  244.  
  245. }
  246. #endif
  247.  
  248. #if qDebug
  249. //----------------------------------------------------------------------------------------
  250. // TObject::PrintAppConstructorClassInfo
  251. //----------------------------------------------------------------------------------------
  252. #pragma segment MADestructorRes
  253. void TObject::PrintAppConstructorClassInfo()
  254. {
  255. ClassName theClassName;
  256. ClassID theClassId;
  257. size_t theClassSize;
  258.  
  259. if (gPrintAppClassInfo)
  260.     {
  261.         this -> GetClassName(theClassName);
  262.         theClassId = this -> GetClassID();
  263.         theClassSize = this -> GetClassSize();    
  264.         fprintf(stderr, "#Construct %s", (char*)theClassName);
  265.         fprintf(stderr, "@ %p", this);
  266.         fprintf(stderr, " Id=%d", theClassId);
  267.         fprintf(stderr, " Size=%d", theClassSize);
  268.         
  269.         if (gObjectCountingEnabled)                
  270.             PrintObjectCount();
  271.         
  272.         fprintf(stderr, "\n");    
  273.     }    
  274.     
  275. }
  276. #endif
  277.  
  278. #if qDebug
  279. //----------------------------------------------------------------------------------------
  280. // TObject::PrintAppDestructorClassInfo
  281. //----------------------------------------------------------------------------------------
  282. #pragma segment MADestructorRes
  283. void TObject::PrintAppDestructorClassInfo()
  284. {
  285. ClassName theClassName;
  286. ClassID theClassId;
  287. size_t theClassSize;
  288.  
  289. if (gPrintAppClassInfo)
  290.     {
  291.         this -> GetClassName(theClassName);
  292.         theClassId = this -> GetClassID();
  293.         theClassSize = this -> GetClassSize();    
  294.         fprintf(stderr, "#Destruct %s", (char*)theClassName);
  295.         fprintf(stderr, "@ %p", this);
  296.         fprintf(stderr, " Id=%d", theClassId);
  297.         fprintf(stderr, " Size=%d", theClassSize);
  298.         
  299.         if (gObjectCountingEnabled)                
  300.             PrintObjectCount();    
  301.             
  302.         fprintf(stderr, "\n");
  303.     }    
  304.  
  305. }
  306. #endif
  307.  
  308. //END Added by C Kopala 6/14/96        
  309. //----------------------------------------------------------------------------------------
  310. // TObject::Hash: 
  311. //----------------------------------------------------------------------------------------
  312. #pragma segment MAObjectRes
  313.  
  314. HashValue TObject::Hash() const
  315. {
  316.     return (long) this >> 2;
  317. } // TObject::Hash
  318.  
  319. //----------------------------------------------------------------------------------------
  320. // TObject::IsSame: 
  321. //----------------------------------------------------------------------------------------
  322. #pragma segment MAObjectRes
  323.  
  324. Boolean TObject::IsSame(const TObject* theObject) const
  325. {
  326.     return this == theObject;
  327. } // TObject::IsSame
  328.  
  329. //----------------------------------------------------------------------------------------
  330. // TObject::IsEqual: 
  331. //----------------------------------------------------------------------------------------
  332. #pragma segment MAObjectRes
  333.  
  334. Boolean TObject::IsEqual(const TObject* /* theObject */) const
  335. {
  336. #if    qDebug
  337.     ProgramBreak("You need to override the IsEqual method");
  338. #endif
  339.  
  340.     return FALSE;
  341. } // TObject::IsEqual
  342.  
  343. //----------------------------------------------------------------------------------------
  344. // TObject::CompareObject: 
  345. //----------------------------------------------------------------------------------------
  346. #pragma segment MAObjectRes
  347.  
  348. ComparisonResult TObject::CompareObject(const TObject* arg) const
  349. {
  350.     if (this->IsLessThan(arg))
  351.         return kLessThan;
  352.     else
  353.     {
  354.         if (this->IsEqual(arg))
  355.         {
  356.             return kEqual;
  357.         }
  358.         else
  359.             return kGreaterThan;
  360.     }
  361. }
  362.  
  363. //----------------------------------------------------------------------------------------
  364. // TObject::IsGreaterThan: 
  365. //----------------------------------------------------------------------------------------
  366. #pragma segment MAObjectRes
  367.  
  368. Boolean TObject::IsGreaterThan(const TObject*) const
  369. {
  370. #if    qDebug
  371.     ProgramBreak("You need to override the IsGreaterThan method");
  372. #endif
  373.  
  374.     return FALSE;
  375. }
  376.  
  377. //----------------------------------------------------------------------------------------
  378. // TObject::IsLessThan: 
  379. //----------------------------------------------------------------------------------------
  380. #pragma segment MAObjectRes
  381.  
  382. Boolean TObject::IsLessThan(const TObject*) const
  383. {
  384. #if qDebug
  385.     ProgramBreak("You need to override the IsLessThan method");
  386. #endif
  387.  
  388.     return FALSE;
  389. }
  390.  
  391. //----------------------------------------------------------------------------------------
  392. // TObject::Changed: 
  393. //----------------------------------------------------------------------------------------
  394. #pragma segment MAObjectRes
  395.  
  396. void TObject::Changed(ChangeID theChange,
  397.                              TObject* changedBy)
  398. {
  399.     TDependencySpace* itsDependencySpace = this->GetDependencySpace();
  400.     if (itsDependencySpace)
  401.         itsDependencySpace->NotifierChanged(this,theChange,changedBy);
  402. } // TObject::Changed 
  403.  
  404. //----------------------------------------------------------------------------------------
  405. // TObject::DoUpdate: 
  406. //----------------------------------------------------------------------------------------
  407. #pragma segment MAObjectRes
  408.  
  409. void TObject::DoUpdate(ChangeID /* theChange */,
  410.                               TObject* /* changedObject */,
  411.                               TObject* /* changedBy */,
  412.                               TDependencySpace* /* dependencySpace */)
  413. {
  414. } // TObject::DoUpdate 
  415.  
  416. //----------------------------------------------------------------------------------------
  417. // TObject::GetDependencySpace: 
  418. //----------------------------------------------------------------------------------------
  419. #pragma segment MAObjectRes
  420.  
  421. TDependencySpace* TObject::GetDependencySpace()
  422. {
  423.     return gMacAppDependencies;
  424. }
  425.  
  426. //----------------------------------------------------------------------------------------
  427. // TObject::AddDependent: 
  428. //----------------------------------------------------------------------------------------
  429. #pragma segment MAObjectRes
  430.  
  431. void TObject::AddDependent(TObject* dependent)
  432. {
  433.     TDependencySpace* itsDependencySpace = this->GetDependencySpace();
  434.     if (itsDependencySpace)
  435.         itsDependencySpace->AddDependency(this, dependent, kNoLabel);
  436. } // TObject::AddDependent 
  437.  
  438. //----------------------------------------------------------------------------------------
  439. // TObject::RemoveDependent: 
  440. //----------------------------------------------------------------------------------------
  441. #pragma segment MAObjectRes
  442.  
  443. void TObject::RemoveDependent(TObject* dependent)
  444. {
  445.     TDependencySpace* itsDependencySpace = this->GetDependencySpace();
  446.     if (itsDependencySpace)
  447.         itsDependencySpace->RemoveDependency(this, dependent, kNoLabel);
  448. } // TObject::RemoveDependent 
  449.  
  450. //----------------------------------------------------------------------------------------
  451. // TObject::RemoveAllDependencies: 
  452. //----------------------------------------------------------------------------------------
  453. #pragma segment MAObjectRes
  454.  
  455. void TObject::RemoveAllDependencies()
  456. {
  457.     TDependencySpace* itsDependencySpace = this->GetDependencySpace();
  458.     if (itsDependencySpace)
  459.         itsDependencySpace->RemoveDependencies(this);                    // Call the routine in UDependencies 
  460. } // TObject::RemoveAllDependencies 
  461.  
  462. //----------------------------------------------------------------------------------------
  463. // TObject::RemoveDependenciesOnFree: 
  464. //----------------------------------------------------------------------------------------
  465. #pragma segment MAObjectRes
  466.  
  467. Boolean TObject::RemoveDependenciesOnFree()
  468. {
  469.     return TRUE;                            // By default we always assume we might have dependents
  470. } // TObject::RemoveDependenciesOnFree 
  471.  
  472. //----------------------------------------------------------------------------------------
  473. // TObject::IsMarked: 
  474. //----------------------------------------------------------------------------------------
  475. #pragma segment MAObjectRes
  476.  
  477. Boolean TObject::IsMarked()
  478. {
  479.     return FALSE;
  480. } // TObject::IsMarked 
  481.  
  482. //----------------------------------------------------------------------------------------
  483. // TObject::SetMark: 
  484. //----------------------------------------------------------------------------------------
  485. #pragma segment MAObjectRes
  486.  
  487. void TObject::SetMark(Boolean /* state */)
  488. {
  489. } // TObject::SetMark 
  490.  
  491. //----------------------------------------------------------------------------------------
  492. // TObject::Clone: 
  493. //----------------------------------------------------------------------------------------
  494. #pragma segment MANonRes
  495.  
  496. TObject* TObject::Clone()
  497. {
  498.  
  499.  
  500.     return this->ShallowClone();
  501. } // TObject::Clone 
  502.  
  503. //----------------------------------------------------------------------------------------
  504. // TObject::GetStandardSignature: 
  505. //----------------------------------------------------------------------------------------
  506. #pragma segment MAWriteResource
  507.  
  508. IDType TObject::GetStandardSignature()
  509. {
  510.     return (this->GetClassDescDynamic())->GetSignature();
  511. } // TObject::GetStandardSignature 
  512.  
  513. //----------------------------------------------------------------------------------------
  514. // TObject::ReadFrom: 
  515. //----------------------------------------------------------------------------------------
  516. #pragma segment MAReadResource
  517.  
  518. void TObject::ReadFrom(TStream* /* aStream */)
  519. {
  520. #if qDebug || qSym
  521.     fClassID = this->GetClassID();
  522. #endif
  523.  
  524. #if qInspector
  525.     pObjectAllocationFlag = FALSE;        // clear the flag
  526.     pLastObject = NULL;
  527. #endif
  528.  
  529. #if qTheDebugger
  530.     TheDbgr_Add_Object(this);
  531. #endif
  532.  
  533. #if qInspector
  534.     if ( NubIsInstalled() )
  535.     {
  536.         ClassName    name;
  537.         
  538.         this->GetClassName(name);
  539.         NubNewObject(this, name);
  540.     }
  541. #endif
  542. } // TObject::ReadFrom 
  543.  
  544. //----------------------------------------------------------------------------------------
  545. // TObject::WriteTo: 
  546. //----------------------------------------------------------------------------------------
  547. #pragma segment MAWriteResource
  548.  
  549. void TObject::WriteTo(TStream* /* aStream */)
  550. {
  551. } // TObject::WriteTo 
  552.  
  553. //----------------------------------------------------------------------------------------
  554. // TObject::Free: 
  555. //----------------------------------------------------------------------------------------
  556. #pragma segment MAObjectRes
  557.  
  558. void TObject::Free()
  559. {
  560.     if (this->RemoveDependenciesOnFree())
  561.         this->RemoveAllDependencies();
  562.  
  563.     this->ShallowFree();
  564. } // TObject::Free 
  565.  
  566. //----------------------------------------------------------------------------------------
  567. // TObject::GetClassName: 
  568. //----------------------------------------------------------------------------------------
  569. #pragma segment MAObjectRes
  570.  
  571. void TObject::GetClassName(ClassName& clName) const
  572. {
  573.     clName = (this->GetClassDescDynamic())->GetClassName();
  574. } // TObject::GetClassName 
  575.  
  576. //----------------------------------------------------------------------------------------
  577. // TObject::GetClassID: 
  578. //----------------------------------------------------------------------------------------
  579. #pragma segment MAObjectRes
  580.  
  581. ClassID TObject::GetClassID() const
  582. {
  583.     return (this->GetClassDescDynamic())->GetClassID();
  584. } // TObject::GetClassID 
  585.  
  586. //----------------------------------------------------------------------------------------
  587. // TObject::GetClassSize: 
  588. //----------------------------------------------------------------------------------------
  589. #pragma segment MAObjectRes
  590.  
  591. size_t TObject::GetClassSize()
  592. {
  593.     return (this->GetClassDescDynamic())->GetClassSize();
  594. } // TObject::GetClassSize 
  595.  
  596. //----------------------------------------------------------------------------------------
  597. // TObject::GetSuperClass: 
  598. //----------------------------------------------------------------------------------------
  599. #pragma segment MAObjectRes
  600.  
  601. const ClassDesc* TObject::GetSuperClass()
  602. {
  603.     return (this->GetClassDescDynamic())->GetBaseClass();
  604. } // TObject::GetSuperClass 
  605.  
  606. //----------------------------------------------------------------------------------------
  607. // TObject::IObject: 
  608. //----------------------------------------------------------------------------------------
  609. #pragma segment MAObjectRes
  610.  
  611. void TObject::IObject()
  612. {
  613. #if qDebug || qSym
  614.     fClassID = this->GetClassID();
  615. #endif
  616.  
  617. #if qInspector
  618.     pObjectAllocationFlag = FALSE;        // clear the flag
  619.     pLastObject = NULL;
  620. #endif
  621.  
  622. #if qTheDebugger
  623.     TheDbgr_Add_Object(this);
  624. #endif
  625.  
  626. #if qInspector
  627.     if ( NubIsInstalled() )
  628.     {
  629.         ClassName    name;
  630.         
  631.         this->GetClassName(name);
  632.         NubNewObject(this, name);
  633.     }
  634. #endif
  635. } // TObject::IObject 
  636.  
  637. //----------------------------------------------------------------------------------------
  638. // TObject::IsSameClass: 
  639. //----------------------------------------------------------------------------------------
  640. #pragma segment MAObjectRes
  641.  
  642. Boolean TObject::IsSameClass(const ClassDesc* classDesc)
  643. {
  644.     return this->GetClassDescDynamic() == classDesc;
  645. } // TObject::IsSameClass 
  646.  
  647. //----------------------------------------------------------------------------------------
  648. // TObject::DescendsFrom: 
  649. //----------------------------------------------------------------------------------------
  650. #pragma segment MAObjectRes
  651.  
  652. Boolean TObject::DescendsFrom(const ClassDesc* classDesc) const
  653. {
  654.     return (this->GetClassDescDynamic())->DescendsFrom(classDesc);
  655. } // TObject::DescendsFrom 
  656.  
  657. //----------------------------------------------------------------------------------------
  658. // TObject::ShallowClone: 
  659. //----------------------------------------------------------------------------------------
  660. #pragma segment MANonRes
  661.  
  662. TObject* TObject::ShallowClone()
  663. {
  664.     TObject * result = (TObject *) operator new (this->GetClassSize());
  665.     MABlockMove(this, result, this->GetClassSize());
  666.  
  667. #if qTheDebugger
  668.     TheDbgr_Add_Object(result);
  669. #endif
  670.     
  671. #if qInspector
  672.     if ( NubIsInstalled() )
  673.     {
  674.         ClassName    name;
  675.         
  676.         this->GetClassName(name);
  677.         NubNewObject(this, name);
  678.     }
  679. #endif
  680.  
  681. #if qDebug
  682. //This section added by C. Kopala 6/30/96
  683. IncrementObjectCount();
  684. if (gPrintAppClassInfo)
  685.     {
  686.         ClassName theClassName;
  687.         ClassID theClassId;
  688.         size_t theClassSize;
  689.         this -> GetClassName(theClassName);
  690.         theClassId = this -> GetClassID();
  691.         theClassSize = this -> GetClassSize();
  692.         fprintf(stderr, " >>Cloned %s", (char*)theClassName);
  693.         fprintf(stderr, "@ %p", result);
  694.         fprintf(stderr, " Id=%d", theClassId);
  695.         fprintf(stderr, " Size=%d", theClassSize);
  696.         
  697.         if (gObjectCountingEnabled)    
  698.             PrintObjectCount();
  699.             
  700.         fprintf(stderr, "\n");
  701.     }
  702. #endif
  703.  
  704.     return result;
  705. } // TObject::ShallowClone 
  706.  
  707. //----------------------------------------------------------------------------------------
  708. // TObject::ShallowFree: 
  709. //----------------------------------------------------------------------------------------
  710. #pragma segment MAObjectRes
  711.  
  712. void TObject::ShallowFree()
  713. {
  714. #if qTheDebugger
  715.     TheDbgr_Delete_Object(this);
  716. #endif
  717.  
  718. #if qInspector
  719.     if ( NubIsInstalled() )
  720.     {
  721.         ClassName    name;
  722.         
  723.         this->GetClassName(name);
  724.         NubObjectFreed(this, name);
  725.     }
  726. #endif
  727.  
  728.     delete this;
  729. } // TObject::ShallowFree 
  730.  
  731. //----------------------------------------------------------------------------------------
  732. // TObject::SubClassResponsibility: 
  733. //----------------------------------------------------------------------------------------
  734. #pragma segment MAObjectRes
  735.  
  736. void TObject::SubClassResponsibility()
  737. {
  738. #if qDebug
  739.     ClassName s;
  740. #endif
  741.  
  742. #if qDebugMsg
  743.     GetCallersMethodName(s);
  744.  
  745.     fprintf(stderr, "%s: must be overridden!", (char *) s);
  746. #endif
  747. } // TObject::SubClassResponsibility 
  748.  
  749. //----------------------------------------------------------------------------------------
  750. //BEGIN Added by C Kopala 6/14/96
  751. #if qDebug
  752. //----------------------------------------------------------------------------------------
  753. // IncrementObjectCount
  754. //----------------------------------------------------------------------------------------
  755. #pragma segment MAGlobalRes
  756. void IncrementObjectCount()
  757. {
  758.     if (gObjectCountingEnabled)
  759.         gObjectCount++;
  760. }
  761. //----------------------------------------------------------------------------------------
  762. // DecrementObjectCount
  763. //----------------------------------------------------------------------------------------
  764. #pragma segment MAGlobalRes
  765. void DecrementObjectCount()
  766. {
  767.     if (gObjectCountingEnabled)
  768.         gObjectCount--;
  769. }
  770. //----------------------------------------------------------------------------------------
  771. // PrintObjectCount
  772. //----------------------------------------------------------------------------------------
  773. #pragma segment MAGlobalRes
  774. void PrintObjectCount()
  775. {
  776.     if (gObjectCountingEnabled)
  777.         fprintf(stderr, " ObjCnt = %d", gObjectCount);
  778. }
  779. //----------------------------------------------------------------------------------------
  780. // DumpClassInfo:
  781. //----------------------------------------------------------------------------------------
  782. #pragma segment MAGlobalRes
  783. void DumpClassInfo()
  784. {
  785. MA_ClassReference aClassDesc;
  786. CClassIterator iter;
  787.  
  788. for (aClassDesc = iter.FirstClassDesc(); iter.More(); aClassDesc = iter.NextClassDesc())
  789.     {
  790.         ClassName theClassName = aClassDesc -> GetClassName();
  791.         ClassID theClassId = aClassDesc -> GetClassID();
  792.         size_t theClassSize = aClassDesc -> GetClassSize();
  793.         
  794.         fprintf(stderr, " %s", (char*)theClassName);
  795.         fprintf(stderr, " classId = %d", theClassId);
  796.         fprintf(stderr, " classSize = %d", theClassSize);
  797.         fprintf(stderr, "\n");
  798.     }
  799. }
  800. //----------------------------------------------------------------------------------------
  801. // DisplayMemoryInfo:
  802. //----------------------------------------------------------------------------------------
  803. #pragma segment MAGlobalRes
  804. void DisplayMemoryInfo()
  805. {
  806.         long availableMemory = 0;
  807.         long heapSize = 0;
  808.         Size tempSize = 0;
  809.         Size szTemporaryReserve;
  810.         Size szMemReserve;
  811.         
  812.         GetReserveSize(szTemporaryReserve,szMemReserve);
  813.                     
  814.         availableMemory = gObjectHeap -> BytesFree();
  815.         heapSize = gObjectHeap -> HeapSize();
  816.         unsigned long freeMemory = FreeMem();
  817.         
  818.         fprintf(stderr, " heapSize = %d", heapSize);
  819.         fprintf(stderr, " availableMemory = %d", availableMemory);
  820.         fprintf(stderr, " used = %d", heapSize - availableMemory);
  821.         fprintf(stderr, "\n");
  822.         fprintf(stderr, " freeMemory = %d", freeMemory);    
  823.         fprintf(stderr, "\n");
  824.         fprintf(stderr, " szTemporaryReserve = %d", szTemporaryReserve);
  825.         fprintf(stderr, " szMemReserve = %d", szMemReserve);
  826.         fprintf(stderr, "\n");
  827.         fprintf(stderr, "\n");
  828. }
  829. //----------------------------------------------------------------------------------------
  830. // InitUDebugGlobals
  831. //----------------------------------------------------------------------------------------
  832. #pragma segment MAGlobalRes
  833. void InitUDebugGlobals()
  834. {
  835. gObjectCount = 0;
  836. gObjectCountingEnabled = FALSE;
  837. gPrintBaseClassInfo = FALSE;
  838. gPrintMacAppClassInfo = FALSE;
  839. gPrintAppClassInfo = FALSE;
  840. gAppUserFlag1 = FALSE;
  841. gAppUserFlag2 = FALSE;
  842. gAppUserFlag3 = FALSE;
  843. }
  844. #endif
  845. //END Added by C Kopala 6/14/96
  846. //----------------------------------------------------------------------------------------
  847. // End of UObject.cp
  848.  
  849. #pragma segment Inline
  850.